{include file="HttpRpc/header" /}

			<div class="content-page">
				<div class="content">
					<div class="container-fluid">
						<div class="row">
							<div class="col-12">
								<div class="card-box">
									<div class="row">
										<div class="col-12">
											<div class="filter-list">
											    <form  action="">
												<div class="row">
													
													<div class="col-md-2 col-xs-6">
														<label>服务路由</label>
														<input type="text" class="form-control" name="class" value="{$param.class|default=''}">
													</div>
													<div class="col-md-2 col-xs-6">
														<label>服务方法</label>
														<input type="text" class="form-control" name="function" value="{$param.function|default=''}">
													</div>
													<div class="col-md-3 col-xs-12">
														<label style="color: #FFF;">1</label>
														<div>
															<button class="btn btn-primary waves-effect waves-light btn-sm" style="float:left;margin: 0 6px 0 0;"> 查詢 </button>
															<button type="button" id="autoReflush" class="btn btn-danger waves-effect waves-light btn-sm" style="float:left">开启自动刷新</button>
                                                            <div id="ms" style="width: auto;float: left;font-size: 13px;margin: 6px;"></div>
														</div>
													</div>
												</div>
												
												<div class="row">
													<div class="col-md-2 col-xs-12">
														<div style="margin-top:5px">
														
														</div>
													</div>
												</div>
												</form>
											</div>
											<div style="margin-top: 20px;">
												<div class="responsive-table-plugin">
													<div class="table-rep-plugin">
														<div class="table-responsive">
															<table id="datatable" class="table table-bordered dt-responsive nowrap">
																<thead>
																	<tr>
                                                                        <th>序号</th>
                                                                        <th>服务地址</th>
                                                                        <th>TC-IP</th>
                                                                        <th>端口</th>
                                                                        <th>是否异步</th>
                                                                        <th>异步通知地址</th>
                                                                        <th>异步类型</th>
                                                                        <th>发生时间</th>
                                                                        <th>操作</th>
																	</tr>
																</thead>
																<tbody>
																    {php}$i=0;{/php}
                                                                    {foreach $list as $v}
                                                                        {foreach $v as $key=>$vv}
                                                                        {php}$vv = json_decode($vv, true);{/php}
                                                                        <tr>
                                                                            <td>{$i+1}</td>
                                                                            <td><font color="#005aff">{$vv.config.class}->{$vv.config.function}</font></td>
                                                                            <td>{$vv.config.ip}</td>
                                                                            <td>{$vv.config.port}</td>
                                                                            <td>{if (isset($vv['config']['task']) && $vv.config.task==1)}<font color="red">是</font>{else /}否{/if}</td>
                                                                            <td>{$vv.config.callback|default=''}</td>
                                                                            <td>{$vv.config.callback_type|default=''}</td>
                                                                            <td>{$vv.config.date|default=''}</td>
                                                                            <td>
                                                                                <input type="hidden" id="{$i}_{$key}_head" value='{:json_encode($vv['config']['headers'], JSON_UNESCAPED_UNICODE)}'>
                                                                                <input type="hidden" id="{$i}_{$key}_param" value='{:json_encode($vv['config']['param'], JSON_UNESCAPED_UNICODE)}'>
                                                                                <input type="hidden" id="{$i}_{$key}_ret" value='{:json_encode($vv['return'], JSON_UNESCAPED_UNICODE)}'>
                                                            
                                                                            <button type="button" class="btn btn-warning waves-effect waves-light btn-sm btn-ty" style="padding: 2px 10px;" onclick="heads('{$i}_{$key}_head')">请求头</button>
																			<button type="button" class="btn btn-warning waves-effect waves-light btn-sm btn-ty" style="padding: 2px 10px;" onclick="param('{$i}_{$key}_param')">请求参数</button>
																			<button type="button" class="btn btn-warning waves-effect waves-light btn-sm btn-ty" style="padding: 2px 10px;" onclick="ret('{$i}_{$key}_ret')">执行结果</button>
																			<button type="button" class="btn btn-primary waves-effect waves-light btn-sm" style="padding: 2px 10px;" onclick="repeat('{$vv.config.class}', '{$vv.config.function}', '{$i}_{$key}')">重发</button>
																			<button type="button" class="btn btn-danger waves-effect waves-light btn-sm" style="padding: 2px 10px;" onclick="deletes('{$vv.config.class}', '{$vv.config.function}', '{$key}')">删除</button>
                                                                            </td>
                                                                        </tr>
                                                                        {php} $i++; {/php}
                                                                        {/foreach}
                                                                    {/foreach}
																</tbody>
															</table>
														</div>
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			
{include file="HttpRpc/footer" /}

<script>
function repeat(cla, func, id) {
    if (confirm('重发并不会在该错误节点下执行！你确定测试【重发】？')) {
        $.ajax({
            type: 'post',
            data: {
                'class':cla,
                'function':func,
                'header':$('#'+id+'_head').val(),
                'param':$('#'+id+'_param').val(),
                'task':$('#'+id+'_task').html(),
                'callback':$('#'+id+'_callback').html(),
                'callback_type':$('#'+id+'_callback_type').html(),
            },
            url: "/HttpRpc/repeat",
            success: function(data) {
                iframe.createIframe('返回值', data, {
                    'height':'500px',
                    'footer':'none',
                    'type':2
                })
            }
        });
    }
}
function deletes(cla, func, redis_index) {
    if (confirm('你确定删除该条记录？')) {
        $.ajax({
            type: 'post',
            data: {
                'class':cla,
                'function':func,
                'redis_index':redis_index,
            },
            url: "/HttpRpc/error_delete",
            success: function(data) {
                var array = eval('('+data+')');
                if (array['code'] == '00') {
                    window.location.reload();
                } else {
                    alert(array['msg']);
                }
            }
        });
    }
}

function heads(id) {
    iframe.createIframe('请求头', '<pre>'+$('#'+id).val()+'</pre>', {
        'height':'500px',
        'width':'500px',
        'footer':'none',
        'type':2
    })
}
function param(id) {
    iframe.createIframe('请求参数', '<pre>'+$('#'+id).val()+'</pre>', {
        'height':'500px',
        'width':'500px',
        'footer':'none',
        'type':2
    })
}
function ret(id) {
    iframe.createIframe('返回值', '<pre>'+$('#'+id).val()+'</pre>', {
        'height':'500px',
        'width':'500px',
        'footer':'none',
        'type':2
    })
}

var fresh;
var stop = false;
$("#autoReflush").click(function(){
    if(!stop){
        $('#ms').html('每5秒自动刷新一次 ');
        //指定5秒刷新一次
        fresh = setInterval(function(){
            window.location.href='?reload=1';
        },5000); 
        $(this).text("关闭自动刷新");
        stop=true;
    }else{
        clearInterval(fresh);
        $(this).text("开启自动刷新");
        $('#ms').html('');
        stop = false;
    }
});
{if (!empty($param['reload']))}
$("#autoReflush").click();
{/if}
</script>